<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>子节点和兄弟节点</title>
</head>

<body>
  <ul>
    <li>1
      <p>12</p>
    </li>
    <li>2</li>
    <li>3</li>
    <li>4</li>
    <li>5</li>
  </ul>
  <script>
    // 拿到亲儿子节点 ,得到一个伪数组
    console.log(document.querySelector('ul').children);
    const li2 = document.querySelector('ul li:nth-child(2)')
    console.log(li2);
    console.log(li2.previousElementSibling);//拿到上一个兄弟节点
    console.log(li2.nextElementSibling);//拿到下一个兄弟节点
  </script>
</body>

</html>